package proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * Created by yangluhua on 2016/9/10 0010.
 */
public class EnhanceService<T> {
    private T t;

    public void setProtoService(T t) {
        this.t = t;
    }

    public void invoke() throws Exception {
        System.out.println("before...");
        Class clazz = t.getClass();
        Method method = clazz.getMethod("check");
        method.invoke(t);
        System.out.println("after...");
    }

    /*@Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("before...");
        Object result = method.invoke(t, args);
        System.out.println("after...");
        return result;
    }*/
}
